public class Num005 {
    //单词长度最大乘积
    public static int maxProduct(String[] words) {
        boolean[][] flags = new boolean[words.length][26];
        for(int i = 0;i < words.length; ++i){
            for(char c: words[i].toCharArray()){
                flags[i] [c - 'a'] = true;
            }
        }
        int result = 0;
        for(int i = 0;i < words.length; ++i){
            for(int j = i + i; j < words.length; ++j){
                int k = 0;
                for(; k < 26; ++k){
                    if(flags[i][k] && flags[j][k]){
                        break;
                    }
                }
                if(k == 26){
                    int prod = words[i].length() * words[j].length();
                    result = Math.max(result,prod);
                }
            }
        }
        return result;
    }
}
